----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/figure_A4_phi_vs_z_servsectors.log
  log type:  text
 opened on:  18 Nov 2022, 11:58:05

. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. keep if type=="serv" 
(315 observations deleted)

. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta" 
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,350
        from master                         0  (_merge==1)
        from using                     12,350  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(12,350 observations deleted)

. drop _merge

. rename DA D_A 

. replace D_A=. if num_aff<3
(1 real change made, 1 to missing)

. 
. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }
(1 missing value generated)
(1 missing value generated)

. levelsof sector, local(seclist)
`"Accomod_Recreat (I-R-S)"' `"Financial_Insurance (K)"' `"Information (J)"' `"Support_Services (M-N)"' `"Transportation_Storage (H)"' `"Wholesale_Retail (G)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_324c_00000o.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_324c_00000o.tmp saved

. 
. 
. *Lopping across all services sectors 
. *----------------------------------------
. foreach selecsec of local seclist {
  2. display "`selecsec'"
  3. 
. use `temp', clear
  4. keep if year==`yy' & sector=="`selecsec'"
  5. sum num_aff
  6. 
. 
. local LHS1 D_`var3'_phi
  7. local LHS2 b_D_`var3'_phi_`grvar0'
  8. local RHS ln_`grvar0'
  9.         
. sum `LHS1' `RHS'  `LHS2'
 10. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"
 11. local xtitle "{&Delta}y{sub:n}"
 12. local firm_emb "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}" 
 13. local ctry_emb "{&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"
 14. 
. reg `LHS1' `RHS' 
 15. mat b = e(b)
 16. mat V = e(V)
 17. global c1: display %-03.2fc round(b[1,1],0.01)
 18. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)
 19. 
. reg `LHS2' `RHS' 
 20. mat b = e(b)
 21. mat V = e(V)
 22. global c2: display %-03.2fc round(b[1,1],0.01)
 23. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)
 24. 
. display $c1
 25. display $se1
 26. display $c2
 27. display $se2
 28. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)
 29. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)
 30. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 
 31. 
. display "`selecsec'"
 32. graph export "${rappendix}/fig_A4_sector_`selecsec'.pdf", replace
 33. 
. }
Accomod_Recreat (I-R-S)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    44.33333    44.05416          3        178

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1685507    .1509606  -.4219094   .1123848
ln_LP_ppp_.. |         27   -.2402669    .2955155  -.9089384   .2338934
b_D_A_phi_~t |         27   -.0717162    .2443539  -.6905414   .3375568

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     11.72
       Model |  .189138599         1  .189138599   Prob > F        =    0.0021
    Residual |  .403378049        25  .016135122   R-squared       =    0.3192
-------------+----------------------------------   Adj R-squared   =    0.2920
       Total |  .592516647        26  .022789102   Root MSE        =    .12702

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2886179   .0842984     3.42   0.002     .1150021    .4622336
            _cons |  -.0992054   .0317463    -3.12   0.004    -.1645881   -.0338227
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     71.21
       Model |  1.14905204         1  1.14905204   Prob > F        =    0.0000
    Residual |  .403378043        25  .016135122   R-squared       =    0.7402
-------------+----------------------------------   Adj R-squared   =    0.7298
       Total |  1.55243009        26   .05970885   Root MSE        =    .12702

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7113821   .0842984     8.44   0.000     .5377664    .8849979
            _cons |   .0992054   .0317463     3.12   0.004     .0338227    .1645881
-----------------------------------------------------------------------------------
.29
.08
.71
.08
Accomod_Recreat (I-R-S)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Accomod_Recreat (I-R-S)
> .pdf written in PDF format)
Financial_Insurance (K)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    50.96296    44.66325         14        231

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.3131005    .2058044  -.6601679   .0680199
ln_LP_ppp_.. |         27    .1389695      .29139  -.4047503   .7605523
b_D_A_phi_~t |         27      .45207    .2736211          0   1.170172

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      5.90
       Model |  .210157664         1  .210157664   Prob > F        =    0.0227
    Residual |  .891084234        25  .035643369   R-squared       =    0.1908
-------------+----------------------------------   Adj R-squared   =    0.1585
       Total |   1.1012419        26  .042355458   Root MSE        =    .18879

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .3085399   .1270656     2.43   0.023     .0468433    .5702364
            _cons |  -.3559782   .0403973    -8.81   0.000    -.4391779   -.2727785
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     29.61
       Model |  1.05549683         1  1.05549683   Prob > F        =    0.0000
    Residual |  .891084225        25  .035643369   R-squared       =    0.5422
-------------+----------------------------------   Adj R-squared   =    0.5239
       Total |  1.94658105        26  .074868502   Root MSE        =    .18879

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .6914601   .1270656     5.44   0.000     .4297636    .9531567
            _cons |   .3559782   .0403973     8.81   0.000     .2727785    .4391779
-----------------------------------------------------------------------------------
.31
.13
.69
.13
Financial_Insurance (K)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Financial_Insurance (K)
> .pdf written in PDF format)
Information (J)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    54.14815    44.59278          2        174

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         26   -.1701298    .1230481  -.4689344   .0733905
ln_LP_ppp_.. |         27   -.2994039     .278164  -.8250313   .1215441
b_D_A_phi_~t |         26   -.1454644     .211636  -.6214744   .2813578

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =     17.85
       Model |  .161472697         1  .161472697   Prob > F        =    0.0003
    Residual |  .217048212        24  .009043675   R-squared       =    0.4266
-------------+----------------------------------   Adj R-squared   =    0.4027
       Total |  .378520909        25  .015140836   Root MSE        =     .0951

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2972296    .070342     4.23   0.000     .1520508    .4424084
            _cons |  -.0763259    .028994    -2.63   0.015    -.1361666   -.0164852
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =     99.82
       Model |  .902696817         1  .902696817   Prob > F        =    0.0000
    Residual |   .21704821        24  .009043675   R-squared       =    0.8062
-------------+----------------------------------   Adj R-squared   =    0.7981
       Total |  1.11974503        25  .044789801   Root MSE        =     .0951

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7027704    .070342     9.99   0.000     .5575916    .8479492
            _cons |   .0763259    .028994     2.63   0.015     .0164852    .1361666
-----------------------------------------------------------------------------------
.3
.07
.7
.07
Information (J)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Information (J).pdf wri
> tten in PDF format)
Support_Services (M-N)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    373.9259    330.7074          8       1349

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.3135533    .1608466  -.6156995          0
ln_LP_ppp_.. |         27   -.2894626     .329522  -1.150283   .2268652
b_D_A_phi_~t |         27    .0240907    .2772609  -.7529141    .392226

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     10.46
       Model |  .198486199         1  .198486199   Prob > F        =    0.0034
    Residual |  .474176174        25  .018967047   R-squared       =    0.2951
-------------+----------------------------------   Adj R-squared   =    0.2669
       Total |  .672662373        26   .02587163   Root MSE        =    .13772

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2651515   .0819651     3.23   0.003     .0963413    .4339616
            _cons |  -.2368019   .0355724    -6.66   0.000    -.3100647   -.1635391
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     80.38
       Model |  1.52453692         1  1.52453692   Prob > F        =    0.0000
    Residual |  .474176161        25  .018967046   R-squared       =    0.7628
-------------+----------------------------------   Adj R-squared   =    0.7533
       Total |  1.99871308        26   .07687358   Root MSE        =    .13772

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7348485   .0819651     8.97   0.000     .5660384    .9036587
            _cons |   .2368019   .0355724     6.66   0.000     .1635391    .3100647
-----------------------------------------------------------------------------------
.27
.08
.73
.08
Support_Services (M-N)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Support_Services (M-N).
> pdf written in PDF format)
Transportation_Storage (H)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    82.33333     56.2385          3        192

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1596197    .1230724  -.3212234    .084976
ln_LP_ppp_.. |         27   -.0798557    .2790346  -.6839539   .5225512
b_D_A_phi_~t |         27    .0797639    .2611976    -.38562   .6818415

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      3.74
       Model |  .051274615         1  .051274615   Prob > F        =    0.0644
    Residual |  .342542421        25  .013701697   R-squared       =    0.1302
-------------+----------------------------------   Adj R-squared   =    0.0954
       Total |  .393817036        26  .015146809   Root MSE        =    .11705

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .1591499   .0822702     1.93   0.064    -.0102887    .3285886
            _cons |  -.1469106   .0234655    -6.26   0.000    -.1952388   -.0985824
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =    104.46
       Model |  1.43128626         1  1.43128626   Prob > F        =    0.0000
    Residual |  .342542419        25  .013701697   R-squared       =    0.8069
-------------+----------------------------------   Adj R-squared   =    0.7992
       Total |  1.77382868        26   .06822418   Root MSE        =    .11705

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |     .84085   .0822702    10.22   0.000     .6714114    1.010289
            _cons |   .1469106   .0234655     6.26   0.000     .0985824    .1952388
-----------------------------------------------------------------------------------
.16
.08
.84
.08
Transportation_Storage (H)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Transportation_Storage 
> (H).pdf written in PDF format)
Wholesale_Retail (G)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    676.2963    506.6227         12       1801

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1612115    .1272924  -.4184586   .0603034
ln_LP_ppp_.. |         27   -.2006866    .2885137  -.8112121   .3667327
b_D_A_phi_~t |         27   -.0394751    .2468879   -.539199   .4798396

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      9.46
       Model |  .115684023         1  .115684023   Prob > F        =    0.0050
    Residual |  .305603182        25  .012224127   R-squared       =    0.2746
-------------+----------------------------------   Adj R-squared   =    0.2456
       Total |  .421287205        26  .016203354   Root MSE        =    .11056

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2311978   .0751547     3.08   0.005     .0764139    .3859817
            _cons |  -.1148132   .0260812    -4.40   0.000    -.1685284    -.061098
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =    104.64
       Model |  1.27919104         1  1.27919104   Prob > F        =    0.0000
    Residual |  .305603177        25  .012224127   R-squared       =    0.8072
-------------+----------------------------------   Adj R-squared   =    0.7995
       Total |  1.58479422        26  .060953624   Root MSE        =    .11056

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7688022   .0751547    10.23   0.000     .6140183    .9235861
            _cons |   .1148132   .0260812     4.40   0.000      .061098    .1685284
-----------------------------------------------------------------------------------
.23
.08
.77
.08
Wholesale_Retail (G)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A4_sector_Wholesale_Retail (G).pd
> f written in PDF format)

. 
. 
. 
. 
end of do-file

. do "F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\code\main\model_07_selection.do"

. *===============================================================================
. *Firm and Country Embedded Productivity (Alviarez, Cravino and Ramondo) 
. *Additive separability (figure6 in CCHK2018 paper) 
. *Last Modified by Vanessa Alviarez 06/2020
. *===============================================================================
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. cap log close
